<?php
class Chuyenmuc extends Database
{
	protected $_tenbang;
	
	protected $_tennhasx;
	protected $_manhasx;
	protected $_tendaodien;
	protected $_madaodien;
	protected $_maquocgia;
	protected $_tenquocgia;
	
	public function __construct()
	{
		$this->connect();
	}
	
	public function setTenbang($tb)
	{
		$this->_tenbang=$tb;
	}
	public function getTenbang()
	{
		return $this->_tenbang;
	}
	
	
	public function sh_chuyenmuc($tbl)
	{
		$sql="select * from $tbl ";
		$this->query($sql);
		if($this->num_rows() !=false)
		{
			while($row=$this->fetch())
			{
				$data[]=$row;
			}
			return $data;
		}
	}
	public function kiemtra_trung($tencot,$row)
	{
		$sql="select * from ".$this->_tenbang." where $tencot='".$row."'";
		$this->query($sql);
		if($this->num_rows()>0)
			return false;
		else
			return true;
	}
	public function them_chuyenmuc($tencot,$gt)
	{
		$sql="insert into ".$this->_tenbang."($tencot) values('".$gt."')";
		$this->query($sql);
	}
	public function xoa_chuyenmuc($tencot,$id)
	{
		$sql="DELETE FROM ".$this->_tenbang." WHERE $tencot = '".$id."'";
		$this->query($sql);
	}
}